<html>

	<head>
		<meta charset="utf-8" />
		<title></title>
	</head>

	<body>
		<script type="text/javascript" src="js/jquery.min.js"></script>
		<script type="text/javascript" src="library/js/city.data-3.js"></script>
		<script>
			var channel = null;
			// 1. 获取支付通道
			function plusReady() {
				// 获取支付通道
				plus.payment.getChannels(function(channels) {
					channel = channels[0];
				}, function(e) {
					alert("获取支付通道失败：" + e.message);
				});
			}
			document.addEventListener('plusready', plusReady, false);
			var ALIPAYSERVER = 'http://demo.dcloud.net.cn/helloh5/payment/alipay.php?total=0.1';
			var WXPAYSERVER = 'http://demo.dcloud.net.cn/helloh5/payment/wxpay.php?total=0.1';
			pay("alipay")
			// 2. 发起支付请求
			function pay(id) {
				// 从服务器请求支付订单
				var PAYSERVER = '';
				if(id == 'alipay') {
					PAYSERVER = ALIPAYSERVER;
				} else if(id == 'wxpay') {
					PAYSERVER = WXPAYSERVER;
				} else {
					plus.nativeUI.alert("不支持此支付通道！", null, "捐赠");
					return;
				}
				var xhr = new XMLHttpRequest();
				xhr.onreadystatechange = function() {
					switch(xhr.readyState) {
						case 4:
							if(xhr.status == 200) {
								plus.payment.request(channel, xhr.responseText, function(result) {
									plus.nativeUI.alert("支付成功！", function() {
										back();
									});
								}, function(error) {
									plus.nativeUI.alert("支付失败：" + error.code);
								});
							} else {
								alert("获取订单信息失败！");
							}
							break;
						default:
							break;
					}
				}
				xhr.open('GET', PAYSERVER);
				xhr.send();
			}
		</script>
		<script>
			var ads = "".split(",");
			console.log(ads)
		</script>
	</body>

</html>